Patching filenames

back to section start!
 
  These routines just deal with the fixing of filenames with strange 
characters in them.  I won't go into them as they don't really have anything 
to do with Opus, just with the idiosyncrasies of AmigaDOS, LZX and LhA. 
 
  1patch:  /* patch filenames containing strange characters */ 
  2  parse arg patched,doapo 
  3  if arctype = 'LZX' then 
  4    strange = '*#?|%()[~' 
  5  else 
  6    strange = '*#?|%()[]~' 
  7  if doapo then 
  8    strange = strange"'" 
  9  pos = 1 
 10  do until here = 0 
 11    here = verify(substr(patched,pos),strange,'m') 
 12    if here > 0 then do 
 13      pos = pos + here + 1 
 14      patched = insert("'",patched,pos - 3) 
 15      end 
 16    end 
 17  if arctype = 'LHA' & left(patched,1) = '@' then 
 18    patched = '%'patched 
 19  if arctype = 'LZX' then 
 20    if length(patched) - lastpos('/',patched) > 30 then 
 21      patched = patched'#?' 
 22  return patched 
 
  1patchstar: 
  2  parse arg remain 
  3  patched = '' 
  4  do until remain = '' 
  5    parse var remain before '*' remain 
  6    patched = patched||before 
  7    if remain ~== '' then 
  8      patched = patched'**' 
  9    end 
 10  return patched 
 
  1lzxkludge: 
  2  parse arg string 
  3  if pos(' ',string) > 0 then 
  4    do while pos("'*",string) > 0 
  5      parse var string fore "'*" aft 
  6      string = fore'?'aft 
  7      end 
  8  if pos('*',string) = 0 then 
  9    string = '"'string'"' 
 10  return string 
 

DOpus PLUS - giving you that bit extra...